package text;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;

/**
 * Created by butterfly on 2018/6/21.
 */
public class Demo_B {
    public static void main(String[] args) {
        Calendar c = Calendar.getInstance();
        System.out.println(c.get(Calendar.YEAR));
        System.out.println(c.get(Calendar.MONTH));//月份起始是从0开始，因此少了一个月
        System.out.println(c.get(Calendar.DATE));
        c.set(2003,10,23,12,23,22);
        System.out.println(c.getTime());
        c.add(Calendar.YEAR,-1);//会自动进位和退位
        c.roll(Calendar.MONTH,-8);//不会自动进位，但会自动退位
        System.out.println(c.getTime());
        //时区类
        TimeZone aDefault = TimeZone.getDefault();//获得机器上的默认时区
        System.out.println(aDefault);
        TimeZone timeZone = TimeZone.getTimeZone("1231233");//根据时区id获取时区
        System.out.println(timeZone);
        String[] ids = TimeZone.getAvailableIDs();
        System.out.println(Arrays.toString(ids));
        System.out.println(aDefault.getID());
        System.out.println(aDefault.getDisplayName());
        System.out.println(TimeZone.getTimeZone("CNT").getDisplayName());;
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("这是yyyy年中第D天哦");
        String format = sdf.format(date);
        System.out.println(format);

    }
}
